<!-- 附件信息 -->
<template>
  <TCollapse title="附件信息">
    <iframe
      ref="myIframeFjRef"
      :src="baseDetailsUrl"
      scrolling="no"
      width="100%"
      :height="basicHeight"
      frameborder="0"
    />
  </TCollapse>
</template>

<script>
import TCollapse from '@/components/basic/TCollapse.vue'
export default {
    name: 'ProjectAttachmentInfo',
    components: {
        TCollapse
    },
    props: {
        paramsObj: {
            type: Object,
            default: () => ({ }),
            required: true
        }
    },
    data() {
        return {
            basicHeight: ''
        }
    },
    computed: {
        baseDetailsUrl() {
            return `${process.env.VUE_APP_ZHONGRUAN_URL}${this.paramsObj.pageSite ? this.paramsObj.pageSite : 'attachmentInfoTodo'}?prjId=${this.paramsObj.prjId}&nodeId=${this.paramsObj.nodeId}&prjStage=${this.paramsObj.prjStage}&btnConfig=${this.paramsObj.btnConfig}&isChange=${this.paramsObj.isChange}&prjType=${this.paramsObj.prjType}&buildModes=${this.paramsObj.buildModes}&towerType=${this.paramsObj.towerType}&roomType=${this.paramsObj.roomType}&orgId=${this.paramsObj.orgId}&projectId=${this.paramsObj.projectId}`
        }
    },
    async created() {
        window.addEventListener('message', (event) => {
            const base_url = ''
              if (event.origin === base_url) {
                return
              }
            if (event.data.type === 'attachment') {
                if (this.$refs.myIframeFjRef !== undefined) {
                    this.$refs.myIframeFjRef.style.height = event.data.height + 'px'
                }
            }
        })
    }
}

</script>
<style lang="scss" scoped></style>
